package com.jwd.avmanager.client;


import com.jwd.avmanager.client.inter.EventListener;
import com.jwd.avmanager.client.inter.EventListenerGroup;
import com.jwd.avmanager.util.DebugLogger;

import java.util.Scanner;

/**
 * @ProjectName: avmanager
 * @Desc: 测试信令交互
 * @Author: david
 * @Date: 2022/2/21
 */
public class TestClient {
    public static void main(String[] args) {
        ProtocolClient client = new ProtocolClient();
        client.connectToServer(new EventListener<Void>() {
            @Override
            public void onSuccess(Void aVoid) {
                DebugLogger.info("连接成功");
            }

            @Override
            public void onError(int errCode) {
                DebugLogger.info("连接失败：" + errCode);
            }
        });
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {

            String text = scanner.next();
            switch (text) {
                case "login":
                    client.login("jwd005", "123456", new EventListener<Boolean>() {
                        @Override
                        public void onSuccess(Boolean aVoid) {
                            if (aVoid)
                                DebugLogger.info("登录成功");
                        }

                        @Override
                        public void onError(int errCode) {
                            DebugLogger.info("登录失败");
                        }
                    });
                    break;
                case "heart":
                    client.startHeartbeat();
                    break;
                case "a":
                    client.getGroupF(new EventListenerGroup<String>() {
                        @Override
                        public void onSuccess(String s) {
                            DebugLogger.info(s);
                        }

                        @Override
                        public void onError(int errCode) {

                        }
                    });
                    break;
                case "b":
                    client.getUserF();
                    break;
                case "d":
                    client.getTalkbackCall();
                    break; 
                case "GPS":
                    client.uploadGPS();
                    break;
                case "EI":
                    client.tagIMEI();
                    break;
                default:
                    break;
            }

        }
    }
}
